public class PreLogACallCtlEx {
    public PreLogACallCtlEx(ApexPages.standardController sc) {}
    public PageReference init() {

        Map<String,String> m = ApexPages.CurrentPage().getParameters().clone();

        // VF controller adds these unexpectedly
        m.remove('id');
        m.remove('save_new');
        
 /*       
        pr.getParameters().put( 'title', m.get('title') );
        pr.getParameters().put( 'type', m.get('type') );
        pr.getParameters().put( 'who_id', m.get('who_id') );   
        pr.getParameters().put( 'what_id', m.get('what_id') );
        pr.getParameters().put( 'followup', m.get('followup') );        
        pr.getParameters().put( 'tsk5', m.get('tsk5') );
*/
                             
        if ( [select Count() from Case where Id=:m.get('what_id')]==1 ) { 
            String origru = EncodingUtil.urlEncode( m.get('retURL') , 'UTF-8');
            String ru = EncodingUtil.urlEncode( Page.StampAFR.getUrl() + '?id=' + m.get('what_id') + '&debug=0&force=1&retURL=' + origru, 'UTF-8' );
            m.put( 'saveURL', ru );
        }
        
        PageReference pr = new PageReference( '/00T/e?nooverride=1' );                
        pr.getParameters().putAll(m);
        return pr;
    }
    static testMethod void testPreLogACallCtlEx() {
        Test.setCurrentPage(Page.PreLogCall);
        Task t = new Task(); insert t;
        ApexPages.standardController sc = new ApexPages.standardController(t);
        PreLogACallCtlEx cx = new PreLogACallCtlEx(sc);
        PageReference pr = cx.init();
        system.assertNotEquals( null,pr );
        system.assertNotEquals( 0,pr.getParameters().keySet().size() );
    }
}